/**
*@author       wuwg
*@createTime   2018/03/20
*@updateTime   2018/03/20
*@description
*@rule
 */
@import "../../../config/config.less";
@import "../../../mixins/select-item/index.less";
@import "../../../mixins/common/index.less";
@import "../../../mixins/icon/index.less";
@import "../input/index.less";

@css-prefix-form-item: ~"@{css-prefix}form-item";
@css-prefix-select: ~"@{css-prefix}select";
@css-prefix-select-item: ~"@{css-prefix}select-item";
@css-prefix-select-group: ~"@{css-prefix}select-group";
@css-prefix-select-dropdown: ~"@{css-prefix}select-dropdown";
@transfer-no-max-height: ~"@{css-prefix}transfer-no-max-height";

.select-error(~"@{css-prefix-form-item}");

// 容器
.@{css-prefix-select} {
  //z-index: 1; // 让浏览器自动获取 z-index,浏览器的容错机制，不兼容再处理
  display: inline-block;
  width: 100%;
  box-sizing: border-box;
  text-align: left;
  vertical-align: middle;
  color: @text-color;
  font-size: @font-size-base;
  //position: relative;
  line-height: normal;
  outline: none;
  user-select: none;
  cursor: pointer;
  position: relative;
  min-height: 30px;


  background-color: #fff;
  border-radius: @btn-border-radius;
  border: 1px solid @border-color-base;
  transition: all @transition-time @ease-in-out;

  // 箭头
  .@{css-prefix-select}-arrow:nth-of-type(1) {
    display: none;
    cursor: pointer;
  }


  // 划过样式
  &:hover {
    .hover();

    .@{css-prefix-select}-arrow:nth-of-type(1) {
      display: inline-block;
    }
  }


  &-show-clear&:hover .@{css-prefix-select}-arrow:nth-of-type(2) {
    display: none;
  }

  //  值箭头
  &-arrow {
    .inner-arrow();
  }

  // 显示下拉菜单时样式
  &-visible {

    /*z-index: 2;*/
    .active();

    //  值箭头
    .@{css-prefix-select}-arrow:nth-of-type(2) {
      transform: rotate(180deg);
    }
  }

  // 获取焦点
  &:focus {
    outline: 0;

    .active();
  }

  //  禁用样式
  &&-disabled {

    // 值容器样式
    .disabled();

    //  值箭头
    .@{css-prefix-select}-arrow:nth-of-type(1) {
      display: none;
    }

    //  禁用划过的样式
    &:hover {
      border-color: @border-color-base;
      box-shadow: none;

      .@{css-prefix-select}-arrow:nth-of-type(2) {
        display: inline-block;
      }
    }
  }

  // 单选下的值容器样式
  &-single {
    height: @input-height-base;
    position: relative;

    // 占位字符颜色
    .@{css-prefix-select}-placeholder {
      color: @input-placeholder-color;
    }

    // 占位字符和值盒子样式
    .@{css-prefix-select}-placeholder,
    .@{css-prefix-select}-selected-value {
      display: block;
      height: @input-height-base - 2px;
      line-height: @input-height-base - 2px;
      font-size: @font-size-small;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      padding-left: 8px;
      padding-right: 24px;
    }
  }

  // 多选下的值容器样式
  &-multiple {
    padding: 0 24px 0 4px;
    //min-height: @input-height-base;

    // 占位字符颜色
    .@{css-prefix-select}-placeholder {
      display: block;
      height: @input-height-base - 2px;
      line-height: @input-height-base - 2px;
      color: @input-placeholder-color;
      font-size: @font-size-small;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      padding-left: 4px;
      padding-right: 22px;
    }
  }

  // input 样式，过滤时用的
  &-input {
    display: inline-block;
    height: @input-height-base;
    line-height: @input-height-base;
    padding: 0 24px 0 8px;
    font-size: @font-size-small;
    outline: none;
    border: none;
    box-sizing: border-box;
    color: @input-color;
    background-color: transparent;
    position: relative;
    cursor: pointer;
    .placeholder();

    &[disabled] {
      cursor: @cursor-disabled;
      color: #ccc;
    }
  }

  // 单选时input 样式，
  &-single &-input {
    width: 100%;
  }

  // 多选时input 样式，
  &-multiple &-input {
    height: @input-height-base - 3px;
    line-height: @input-height-base;
    padding: 0 0 0 4px;
    width: 20px;
  }

  // 没有下拉数据条目的样式
  &-not-found {
    text-align: center;
    color: @btn-disable-color;
  }

  // 加载文字的样式
  &-loading {
    text-align: center;
    color: @btn-disable-color;
  }

  // 多选标签的样式
  &-multiple .@{css-prefix}tag {
    position: relative;
    margin: 3px 4px 3px 0;
    padding-right: 20px;
    max-width: 100%;
    height: 24px;
    line-height: 22px;

    .@{css-prefix}tag-text {
      display: inline-block;
      max-width: 100%;
      white-space: nowrap;
      text-overflow: ellipsis;
      overflow: hidden;
    }

    .@{css-prefix}icon {
      position: absolute;
      right: 0;
      top: 50%;
      margin-left: 0;
      width: 18px;
      -webkit-transform: translate(0, -50%) scale(1.42857143) rotate(0deg);
      -moz-transform: translate(0, -50%) scale(1.42857143) rotate(0deg);
      -ms-transform: translate(0, -50%) scale(1.42857143) rotate(0deg);
      -o-transform: translate(0, -50%) scale(1.42857143) rotate(0deg);
      transform: translate(0, -50%) scale(1.42857143) rotate(0deg);
      text-align: center;
    }
  }

  // 大型多选标签的样式
  &-large&-multiple .@{css-prefix}tag {
    height: 28px;
    line-height: 26px;
    font-size: @font-size-base;
  }

  // 小型多选标签的样式
  &-small&-multiple .@{css-prefix}tag {
    height: 17px;
    line-height: 15px;
    font-size: @font-size-small;
    padding: 0 6px;
    margin: 3px 4px 2px 0;
  }

  // 下拉菜单
  &-dropdown-list {
    list-style: none;
  }
}

// option条目
.select-item(@css-prefix-select, @css-prefix-select-item);

.@{css-prefix-select-item} {
  position: relative;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.@{css-prefix-select-dropdown} .@{css-prefix-select-item} span {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

// 多选
.@{css-prefix-select}-multiple .@{css-prefix-select-item} {
  &-selected {
    color: @selected-color;
    background: #fff;
  }

  &-focus,
  &-selected:hover {
    color: @selected-color;
    background: @background-color-select-hover;
  }

  &-selected&-focus {
    color: shade(@selected-color, 10%);
    background: #fff;
  }

  &-selected:after {
    .icon();
    position: absolute;
    top: 50%;
    right: 10px;
    z-index: 2;
    -webkit-transform: translate(0, -50%);
    -moz-transform: translate(0, -50%);
    -ms-transform: translate(0, -50%);
    -o-transform: translate(0, -50%);
    transform: translate(0, -50%);
    font-size: 24px;
    content: '\F3FD';
    color: @selected-color;
  }
}


.@{css-prefix-select-dropdown} {
  width: auto;
  max-height: 240px;
  overflow: auto;
  margin: 5px 0;
  padding: 5px 0;
  background-color: #fff;
  box-sizing: border-box;
  //border: 1px solid @border-color-split;
  border-radius: @btn-border-radius;
  //box-shadow: 0 1px 3px rgba(0,0,0,.2);
  box-shadow: @select-shaow;
  position: absolute;
  z-index: @zindex-select;
  border: @select-border;

  &.slide-up {
    transform-origin: center top;
  }

  &.slide-down {
    bottom: 100%;
    transform-origin: center bottom;
  }

  &-transfer {
    z-index: @zindex-transfer;
    // 以下两个样式是为了解决transfer的情况下,下拉列表,日期控件等在IE下会导致闪动问题
    // 经排查得知此问题是因为它监控visible先将弹出层显示出来了然后在通知popper去更新位置, IE渲染机制不好导致显示出来的时候重排一次,
    // 计算完位置的时候再重排一次, 瞬间出现了竖滚导致居中布局闪动了.. modify by yuanzhy 2018-12-11
    top: -1000px;
    left: -2000px;
  }

  &.@{transfer-no-max-height} {
    max-height: none;
  }

  // 下拉树
  .@{css-prefix}tree {
    max-height: 240px;
    border: none;
  }

  // 下拉树
  .@{css-prefix}tree-search {
    margin-left: 5px;
    margin-right: 5px;
  }
}




// option group
.@{css-prefix-select-group} {
  list-style: none;
  margin: 0;
  padding: 0;

  &-title {
    padding-left: 8px;
    font-size: 12px;
    color: @legend-color;
    height: 30px;
    font-weight: normal;
    line-height: 30px;
  }
}

.select-error(@class) {
  .@{class}-error {
    .@{css-prefix-select} {
      border: 1px solid @error-color  !important;

      &-arrow {
        color: @error-color;
      }

      &-visible.@{css-prefix-select} {
        .active-error();
      }
    }

    // 划过
    .@{css-prefix-select}:hover {
      .hover-error();
    }

    // 获得焦点
    .@{css-prefix-select}:focus {
      .active-error();
    }
  }
}
